<form action="index.php" method="post" name="adminForm">
<script>
  jQuery(document).ready(function(){
    create_tab("#tabs");
    jQuery(".tablesorter").tablesorter({sortList: [[3,1],[1,1],[2,1],[4,1],[5,1],[6,1],[7,1],[8,1],[0,1]]}); 
  });
</script>

<div id="tabs" style="padding-top:10px;">
  <ul>
  <? foreach($this->divisions as $division):?>
    <li><a href="#conference-<?= $division->id ?>"><?= $division->name ?></a></li>
  <? endforeach; ?>
  </ul>
    
  <?  foreach($this->divisions as $division):  ?>
    <div id="conference-<?= $division->id ?>">
    <?  foreach($division->conferences as $conference): ?>
      <div id="<?= $conference->name ?>">
        <table style="margin-bottom:1em; width:600px; margin:auto;" class="tablesorter">
          <thead>
            <tr><td colspan="9" style="letter-spacing:-1px;font-size:1.4em;font-weight:bold;padding:10px 0px 15px;"><?= $conference->name ?></td></tr>
            <tr>
              <th class="cell_key">Teams</th>
              <th class="cell_key">W</th>
              <th class="cell_key">L</th>
              <th class="cell_key">PCT</th>
              <th class="cell_key">GB</th>
              <th class="cell_key">PTS MADE</th>
              <th class="cell_key">PTS ALWD</th>
              <th class="cell_key">PTS DIFF</th>
              <th class="cell_key">L3</th>
              <th class="cell_key">STREAK</th>
            </tr>
          </thead>
          <tbody>
          <? foreach($conference->teams as $team){ 
              if(!isset($team->standing))
                continue;
          ?>
            <tr>
              <td class="cell_value"><?= $team->name ?></td>
              <? $standing = $team->standing; ?>
              <td class="cell_value"><?= $standing['wins'] ?></td>
              <td class="cell_value"><?= $standing['loss'] ?></td>
              <td class="cell_value"><?= $standing['pct'] ?></td>
              <td class="cell_value"><?= $standing['gb']?></td>
              <td class="cell_value"><?= $standing['pmade'] ?></td>
              <td class="cell_value"><?= $standing['palwd'] ?></td>
              <td class="cell_value"><?= $standing['diff'] ?></td>
              <td class="cell_value"><?= $standing['l3'] ?></td>
              <td class="cell_value"><?= $standing['streak'] ?></td>
            </tr>
          <? }?>
          </tbody>
        </table>
      </div>
      <script>
        jQuery(document).ready(function(){
          create_header("#<?= $conference->name ?>", "600px");
        });
      </script>
    <?  endforeach; ?>
    </div>
  <?  endforeach; ?>  
</div>

</form>